package com.ffcs.cn.action.common;

import com.supermap.desktop.controls.ui.controls.colorSelect.SmButtonColorSelector;
import com.supermap.desktop.core.event.colorSelect.IColorChangedListener;
import com.supermap.desktop.core.ui.controls.GridBagConstraintsHelper;
import com.supermap.desktop.core.ui.controls.SMSpinner;
import com.ffcs.cn.DevelopProperties;

import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;

/**
 * 点对象风格设置面板
 *
  */
public abstract class StyleSettingPanelPoint extends AbstractStyleSettingPanel {

	protected JLabel jLabelSymbolColor;
	protected SmButtonColorSelector buttonSymbolColor;

	protected JLabel jLabelWidth;
	protected SMSpinner spinnerWidth;

	protected JLabel jLabelHeight;
	protected SMSpinner spinnerHeight;

	protected JLabel jLabelMarkerAngle;
	protected SMSpinner spinnerMarkerAngle;

	protected JLabel jLabelAlpha;
	protected SMSpinner spinnerOpaqueRate;

	public StyleSettingPanelPoint() {
		jLabelSymbolColor = new JLabel(DevelopProperties.getString("String_Label_SymbolColor"));
		buttonSymbolColor = new SmButtonColorSelector();

		jLabelHeight = new JLabel(DevelopProperties.getString("String_Label_SymbolHeight"));
		spinnerHeight = new SMSpinner(new SpinnerNumberModel(0.0, 0.0, 500, 0.1));

		jLabelWidth = new JLabel(DevelopProperties.getString("String_Label_SymbolWidth"));
		spinnerWidth = new SMSpinner(new SpinnerNumberModel(0.0, 0.0, 50.0, 0.1));

		jLabelMarkerAngle = new JLabel(DevelopProperties.getString("String_Label_Angel"));
		spinnerMarkerAngle = new SMSpinner(new SpinnerNumberModel(0.0, 0.0, 360, 1));

		jLabelAlpha = new JLabel(DevelopProperties.getString("String_Label_OpaqueRate"));
		spinnerOpaqueRate = new SMSpinner(new SpinnerNumberModel(0, 0, 100, 1));
		initLayout();
		registerEvents();
	}

	private void initLayout() {
		this.setLayout(new GridBagLayout());
		this.add(jLabelSymbolColor, new GridBagConstraintsHelper(0, 0, 1, 1)
				.setAnchor(GridBagConstraints.WEST)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP)
				.setFill(GridBagConstraints.NONE)
				.setWeight(0, 0));
		this.add(buttonSymbolColor, new GridBagConstraintsHelper(1, 0, 2, 1)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setAnchor(GridBagConstraints.WEST)
				.setFill(GridBagConstraints.HORIZONTAL)
				.setWeight(1, 0));
		this.add(jLabelHeight, new GridBagConstraintsHelper(0, 1, 1, 1)
				.setAnchor(GridBagConstraints.WEST)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP)
				.setFill(GridBagConstraints.NONE)
				.setWeight(0, 0));
		this.add(spinnerHeight, new GridBagConstraintsHelper(1, 1, 2, 1)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setAnchor(GridBagConstraints.WEST)
				.setFill(GridBagConstraints.HORIZONTAL)
				.setWeight(1, 0));
		this.add(jLabelWidth, new GridBagConstraintsHelper(0, 2, 1, 1)
				.setAnchor(GridBagConstraints.WEST)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP)
				.setFill(GridBagConstraints.NONE)
				.setWeight(0, 0));
		this.add(spinnerWidth, new GridBagConstraintsHelper(1, 2, 2, 1)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setAnchor(GridBagConstraints.WEST)
				.setFill(GridBagConstraints.HORIZONTAL)
				.setWeight(1, 0));
		this.add(jLabelMarkerAngle, new GridBagConstraintsHelper(0, 3, 1, 1)
				.setAnchor(GridBagConstraints.WEST)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP)
				.setFill(GridBagConstraints.NONE)
				.setWeight(0, 0));
		this.add(spinnerMarkerAngle, new GridBagConstraintsHelper(1, 3, 2, 1)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setAnchor(GridBagConstraints.WEST)
				.setFill(GridBagConstraints.HORIZONTAL)
				.setWeight(1, 0));
		this.add(jLabelAlpha, new GridBagConstraintsHelper(0, 4, 1, 1)
				.setAnchor(GridBagConstraints.WEST)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP)
				.setFill(GridBagConstraints.NONE)
				.setWeight(0, 0));
		this.add(spinnerOpaqueRate, new GridBagConstraintsHelper(1, 4, 2, 1)
				.setInsets(GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setAnchor(GridBagConstraints.WEST)
				.setFill(GridBagConstraints.HORIZONTAL)
				.setWeight(1, 0));
	}

	private void registerEvents() {
		buttonSymbolColor.addColorChangedListener(getSymbolColorChangeListener());
		spinnerHeight.addChangeListener(getHeightChangeListener());
		spinnerWidth.addChangeListener(getWidthChangeListener());
		spinnerMarkerAngle.addChangeListener(getMarkerAngleChangeListener());
		spinnerOpaqueRate.addChangeListener(getAlphaChangeListener());
	}

	/**
	 * 颜色值改变的监听器
	 *
	 * @return 监听器
	 */
	public abstract IColorChangedListener getSymbolColorChangeListener();

	/**
	 * 符号高度改变监听器
	 *
	 * @return 监听器
	 */
	public abstract ChangeListener getHeightChangeListener();

	/**
	 * 符号宽度改变的监听器
	 *
	 * @return 监听器
	 */
	public abstract ChangeListener getWidthChangeListener();

	/**
	 * 符号角度改变监听器
	 *
	 * @return 监听器
	 */
	public abstract ChangeListener getMarkerAngleChangeListener();

	public abstract ChangeListener getAlphaChangeListener();

}
